# -*- codeing = utf-8 -*-
# @Time : 2021/4/27 9:35
# @Author : Alan_Sheng
# @File : MySQLHelper.py
# @Software : PyCharm

import pymysql


class MySQLHelper:
    def __init__(self):
        try:
            self.conn = pymysql.connect(host="localhost", user="root", password="root", port=3306, database="")
            print("conn success!")
        except Exception as e:
            print("conn error:" + e)

    def executeForUCD(self, sql, params):
        self.cuser = self.conn.cursor()
        i = self.cuser.execute(sql, params)

        self.conn.commit()
        self.close()
        print(i)
        return i

    def ececuteForSelectOne(self,sql,params):
        self.cursor=self.conn.cursor()
        self.cursor.execute(sql,params)
        rs=self.cursor.fetchone()

    def executeForSelectAll(self,sql,parms):
        self.cursor=self.conn.cursor()

    def close(self):
        pass


pymysql = MySQLHelper()
